package hot_100;

/**
 * @author: Darven
 * @createTime: 2025-09-28  00:56
 * @description: TODO
 */
public class P35 {
    public int searchInsert(int[] nums, int target) {
        int l=0;
        int r=nums.length-1;
        int mid=0;
        while(l<=r){
            mid=(l+r)>>1;
            if(nums[mid]==target){
                return mid;
            }
            else if(nums[mid]>target){
                r=mid-1;
            }
            else{
                l=mid+1;
            }
        }

        return mid+1;
    }
}
